// Set background and border to a block in order to debug the grid.
@mixin debug-cell() {
  background-color: rgba(86,61,124,.15);
  border: 1px solid rgba(86,61,124,.2);
}

// Generate column classes, for example col-md-[n].
@mixin sb-add-column-classes($class, $grid-columns) {
  @for $i from 1 through $grid-columns {
    .col-#{$class}-#{$i} {
      @include span($i of $grid-columns);
      min-height: 1px;
      position: relative;
    }
  }
}

// Generate offset classes, for example col-md-offset-[n].
@mixin sb-add-offset-classes($class, $grid-columns) {
  @for $i from 0 through $grid-columns {
    .col-#{$class}-offset-#{$i} {
      @include pre($i of $grid-columns);
    }
  }
}

// Generate pull classes, for example col-md-pull-[n].
@mixin sb-add-pull-classes($class, $grid-columns) {
  @for $i from 0 through $grid-columns {
    @if ($i > 0) {
      .col-#{$class}-pull-#{$i} {
        right: percentage(($i / $grid-columns));
      }
    }
    @else if ($i == 0) {
      .col-#{$class}-pull-0 {
        right: auto;
      }
    }
  }
}

// Generate push classes, for example col-md-push-[n].
@mixin sb-add-push-classes($class, $grid-columns) {
  @for $i from 0 through $grid-columns {
    @if ($i > 0) {
      .col-#{$class}-push-#{$i} {
        left: percentage(($i / $grid-columns));
      }
    }
    @else if ($i == 0) {
      .col-#{$class}-push-0 {
        left: auto;
      }
    }
  }
}

// Add properties to a container.
@mixin sb-make-default-container() {
  @include container();
  padding: 0 gutter();
  @include susy-clearfix;
}

// Add properties to a row.
@mixin sb-make-row() {
  margin: 0 gutter() * -1;

  @if $debug == true {
    & > div {
      @include debug-cell;
    }
  }
  @include susy-clearfix;
}

// Generate all column-level classes.
@mixin sb-make-grid($class, $grid-columns) {
  // Column classes for extra small screens and up.
  @include sb-add-column-classes($class, $grid-columns);
  // Offset classes for extra small screens and up.
  @include sb-add-offset-classes($class, $grid-columns);
  // Pull classes for extra small screens and up.
  @include sb-add-pull-classes($class, $grid-columns);
  // Push classes for extra small screens and up.
  @include sb-add-push-classes($class, $grid-columns);
}
